#include <stdlib.h>
#include <stdio.h>
#include <string.h>

char * substring(char *buffer, char *sub){
	while(*buffer != '\0'){
		if(*sub == *buffer){
			char *bufferCount = buffer;
			char *subCount = sub;

			while(*bufferCount != '\0' && *subCount != '\0' && *bufferCount == *subCount){
				bufferCount += sizeof(char);
				subCount += sizeof(char);
			}

			if(*subCount == '\0'){
				return buffer;
			}
		}

		buffer += sizeof(char);
	}

	return NULL;
}

int main(){
	char *str1 = (char *) malloc(40 * sizeof(char));
	char *str2 = (char *) malloc(40 * sizeof(char));

	str1 = "this is freeze-safe.file";
	str2 = "freeze-safe.file";

	printf("substring(%s, %s) is (%s)\n", str1, str2, substring(str1, str2));
}
